import { useHistory } from 'react-router-dom';
import { Button, Table, Space, Popconfirm, message } from 'antd';
import './UserV.css';



const UserV = () => {

    const his = useHistory();
    //跳转添加
    const toAdd = (i) => {
        console.log(i);
        his.push('/admin/UserAdd');
    }
    //跳转修改
    const hiss = useHistory();
    const clickA = (ev) => {

        console.log(ev.target.dataset.index);
        if (ev.target.dataset.index == "1") {
            hiss.push('/admin/UserEdit');
        }
    }
    //气泡删除的方法
    const confirm=(e)=> {
        console.log(e);
        message.success('Click on Yes');
      }
      
      const cancel=(e)=> {
        console.log(e);
        message.error('Click on No');
      }
    //表格
    const columns = [
        {
            title: '角色名称',
            dataIndex: 'name',
            key: 'name',
            render: text => <a>{text}</a>,
        },
        {
            title: '自动升级',
            dataIndex: 'source',
            key: 'source',
        },
        {
            title: '操作人员',
            dataIndex: 'phone',
            key: 'phone',
        },
        {
            title: '更新时间',
            dataIndex: 'time',
            key: 'time',
        },
        // {
        //     title: '操作',
        //     key: 'action',
        //     render: (v, record) => (
        //         <Space size="middle">
        //             <a data-index="1" onClick={clickA}>编辑</a>
        //             <Popconfirm
        //                 title="确认删除吗?"
        //                 onConfirm={confirm}
        //                 onCancel={cancel}
        //                 okText="Yes"
        //                 cancelText="No"
        //             >
        //             <a data-index="2" onClick={clickA}>删除</a>
        //             </Popconfirm>

        //         </Space>
        //     ),
        // }
    ];
    // 渲染数据
    const data = [
        {
            key: '1',
            name: '黄金会员',
            source: '开启',
            phone: 'admin',
            time: '2019-06-05',
        },
        {
            key: '2',
            name: '铂金会员',
            source: '开启',
            phone: 'admin',
            time: '2019-06-05',
        },
        {
            key: '3',
            name: '钻石会员',
            source: '开启',
            phone: 'admin',
            time: '2019-06-05',
        },
        {
            key: '4',
            name: '海带小会员',
            source: '开启',
            phone: 'admin',
            time: '2019-06-05',
        }

    ];
    return (
        <div className="detail hy">
            {/* <Button type="primary" className="btn" onClick={toAdd}>添加</Button> */}
            {/* 表格 */}
            <div className="mt-2">
                <Table
                    columns={columns}
                    dataSource={data}
                    pagination={false}
                    onRow={record => {
                        return {
                            onClick: event => {
                                console.log(record);
                            },
                        };
                    }}
                />
            </div>

        </div>
    )
}
export default UserV;